@extends('layouts.template')

@section('title', '管理后台')

@section('content')

    <script type="text/javascript" charset="utf-8" src="{{asset('js/ueditor/ueditor.config.js')}}"></script>
    <script type="text/javascript" charset="utf-8" src="{{asset('js/ueditor/ueditor.all.min.js')}}"> </script>
    <script>
        var selectedMenu = 'article/bannerlist';
        var selectedTitle = '添加Banner';

        $(function(){

            var form = new Vue({
                el:'#contentpanel',
                data:{
                },
                computed:{
                },
                mounted:function(){
                },
                watch: {
                },
                methods:{
                },
                components:{
                }
            });

            var validator = $("#form").validate({
                rules: {
                    name:{
                        required:true,
                        minlength:1,
                        maxlength:20,
                    },
                    sort:{
                        required:true,
                    },
                    url:{
                        url:true,
                    },
                    banner_img:{
                        required:true,
                    },
                },
                messages: {
                    name:{
                        required:'请填写名称',
                        maxlength:'不要超过20个字',
                    },
                    sort:{
                        required:'请填写排序数字',
                    },
                    url:{
                        required:'请填写正确的链接',
                    },
                    banner_img:{
                        required:'请选择上传图片',
                    },
                },
                submitHandler: function(form) {
                    form.submit();
                },
            });

        });

    </script>

    <div class="contentpanel" id="contentpanel">
        <div class="row">
            <div class="col-md-9">
                <form id="form" method="POST" action="" enctype="multipart/form-data">
                    {{csrf_field()}}
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <!-- 左侧表单 begin-->
                            <div class="col-md-6">
                                <div class="row">

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">名称： <span class="asterisk">*</span></label>
                                        <div class="col-sm-9">
                                            <input type="text" name="name" class="form-control" required="required" value="{{ old('name') }}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">排序数字：<span class="asterisk">*</span>
                                            <p>(默认由大到小排序)</p> </label>
                                        <div class="col-sm-3">
                                            <input type="text" name="sort" class="form-control" required="required" value="{{ old('sort',0) }}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">链接： </label>
                                        <div class="col-sm-9">
                                            <input type="text" name="url" class="form-control" required="required" value="{{ old('url') }}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">上传图片： <span class="asterisk">*</span></label>
                                        <div class="col-sm-9">
                                            <input type="file" name="_banner_img" class="form-control" value="{{ old('_banner_img') }}">(建议宽高比是2:1)
                                        </div>
                                    </div>

                                </div><!-- row -->
                            </div>
                            <!-- 左侧表单 end-->
                        </div><!-- panel-body -->
                        <div class="panel-footer">
                            <div class="row">
                                <div class="col-sm-9 col-sm-offset-3">
                                    <button class="btn btn-primary mr5" type="submit">保存</button>
                                    <a href="{{$_refer}}" class="btn btn-dark">取消</a>
                                </div>
                            </div>
                        </div><!-- panel-footer -->
                    </div><!-- panel -->
                </form>
            </div>
        </div>
    </div>


@endsection

